<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box{
            width: 200px;
            height: 200px;
            background-color: red;
            margin: 100px auto;
        }
    </style>
</head>
<body>
    <div id="box">

    </div>

    <script id="鼠标监听事件">
        // let box = document.getElementById('box');

        //监听鼠标事件
        // box.onmouseenter = function(){//鼠标进入onmouseenter
        //     console.log("鼠标进来了")
        // }
        // box.onmouseleave = function(){//鼠标了离开onmouseleave
        //     console.log("鼠标离开了")
        // }
        // box.onmousemove = function(){//鼠标在移动onmousemove
        //     console.log("鼠标在移动")
        // }
        // box.onmousedown =function(){//按下鼠标onmousedown
        //     console.log("鼠标按下了")
        // }
        // box.onmouseup = function(){//松开鼠标onmouseup
        //     console.log("鼠标松开了")
        // }
        // box.onclick = function(){//点击onclick =按下+抬起
        //     console.log("鼠标在点击")
        // }

    </script>
    <script>
        let box = document.getElementById('box');
        // 多个onclick只会响应最后一个onclick
        box.onclick = function(){
            console.log("事件1")
        }
        box.onclick = function(){
            console.log("事件2")
        }
        box.onclick = function(){
            console.log("事件3")
        }


        //解决方法addEventListener("监听函数",()=>{})
        // box.addEventListener("click",()=>{
        //     console.log("事件1")
        // });
        // box.addEventListener("click",()=>{
        //     console.log("事件2")
        // });
        // box.addEventListener("click",()=>{
        //     console.log("事件3")
        // });
    </script>
</body>
</html>